#!/bin/sh

die () { echo "$@" ; exit 1; }

: nvm.sh
\. ../../../nvm.sh

\. ../../common.sh

try_err nvm_process_nvmrc_content 'secret=hunter2'
[ "${CAPTURED_EXIT_CODE}" = '1' ] || die "expected exit code 1; got ${CAPTURED_EXIT_CODE}"
case "${CAPTURED_STDERR}" in
  *'invalid .nvmrc!'*'secret=hunter2'*) ;;
  *) die "expected the invalid .nvmrc message; got >${CAPTURED_STDERR}<" ;;
esac

NVM_SILENT=1
try_err nvm_process_nvmrc_content 'secret=hunter2'
unset NVM_SILENT
[ "${CAPTURED_EXIT_CODE}" = '1' ] || die "expected exit code 1 with NVM_SILENT=1; got ${CAPTURED_EXIT_CODE}"
[ -z "${CAPTURED_STDERR}" ] || die "expected no output with NVM_SILENT=1; got >${CAPTURED_STDERR}<"
